﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Budgeter.Extensions;

namespace Budgeter.ViewModels.Budget.Index
{

    public class Loader : ILoader<IEnumerable<Models.Budget>, ViewModel>
    {
        public ViewModel Load(Models.BudgeterContext db, IEnumerable<Models.Budget> source)
        {
            ViewModel vm = new ViewModel
            {
                Items = from m in source
                        select new ViewModel.Item
                        {
                            CreatedUtc = m.CreatedUtc,
                            ExpenseFortnightlyTotal = m.GetFortnightlyExpense(),
                            IncomeFortnightlyTotal = m.GetFortnightlyIncome(),
                            ReceiptNumber = Receipt.FormatReceiptNumber(m.ReceiptNumber),
                        }
            };
            return vm;
        }

        public void PopulateDataForView(Models.BudgeterContext db, ViewModel model)
        {
        }
    }

}